<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
    <style>
        .current {
            color: orange;
        }
    </style>
</head>
<body>
    <div id='app'>
        {{msg}}
        <show></show>
        <show>
            <span>******************</span>
            <p>插槽页面内容一</p>
            <p>插槽页面内容二</p>
        </show>
        <show>
            <!-- //页面实际显示的顺序是按照模板的顺序，然后根据具名插槽渲染来的，并不是这里标签顺序来 -->
            <span>============</span><br>
            <span slot="aa">测试具名插槽一</span>
            <span>测试具名插槽二</span>
        </show>

        <show :list="list">
            <template slot-scope="obj">
                <strong v-if="obj.info.id == 2" class="current">{{obj.info.fruitname}}</strong>
                <span v-else>{{obj.info.fruitname}}</span>
            </template>
        </show>
    </div>
    <script type='text/javascript'>
        // 全局组件
        Vue.component('show',{
            props: ['list'],
            template: `
            <div>
                <ul>
                    <li v-for="item in list" :key="item.id">
                        <slot :info="item"></slot>    
                    </li>
                </ul>
            </div>
            `,
        })
        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue',
                list: [{
                    id: 1,
                    fruitname: 'apple'
                }, {
                    id: 2,
                    fruitname: 'orange'
                }, {
                    id: 3,
                    fruitname: 'banana'
                }]
            }
        });
    </script>
</body>
</html>